package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import java.util.*;

class PlayerLevel2Fall4 extends PlayerLevel2
{
protected StateImageLibrary ladderimages;
protected int imagesindex = 0;
public PlayerLevel2Fall4(int startx, int starty)
{
	super(startx, starty);
	ladderimages = new StateImageLibrary();
	ladderimages.addImage("playerman100x150-1.png");
/*
	ladderimages.addImage("playerman100x150-ladder-2.png");
	ladderimages.addImage("playerman100x150-ladder-3.png");
	ladderimages.addImage("playerman100x150-ladder-4.png");
	ladderimages.addImage("playerman100x150-ladder-3.png");
	ladderimages.addImage("playerman100x150-ladder-2.png");
*/
}

public void fall()
{
	    if (playery > 150)
		playery = 150-1;

}

public Image getImage()
{
	if (imagesindex > 0)//FIXME1 6)//ladderimages.size())
		imagesindex = 0;
	return ladderimages.getImage(imagesindex);
}

public void moveP()//FIXME moveP
{
	
  	int foo = movePWithKeyLevel2(key);
	if (foo > 0 && getx() >= 394) {
		//FIXME mapx+=5.0;
      	}

  	shootP(key, friendlybullets);
}

public int movePWithKeyLevel2(int key)
{
	   int foo = 0;
           if (key == KeyEvent.VK_UP)//NOTE1
            {
		playery += -5;
		imagesindex++;
		foo = 1;
            }
            else if (key == KeyEvent.VK_DOWN)
            {
		playery += 5;
		imagesindex++;
		foo = 2;
            }
	    else 
	    {
		foo = 3;
		//direction = "nowhere";
		//prevdirection = "nowhere";
	    }

	   //if (foo > 0 && playerx >= 400)
		//playerx -= 5;
	return foo;
}

public void shootP(int key, LinkedList<Bullet> l)
{
            if (key == KeyEvent.VK_F)
            {
		if (prevdirection == "right") {
			Bullet bullet = new Bullet(getx()+50,gety()+80,"bullet16x16-1.png");
			bullet.setdx(+6);
			l.add(bullet);
		}
		else if (prevdirection == "left") {
			Bullet bullet = new Bullet(getx(),gety()+80,"bullet16x16-1.png");
			bullet.setdx(-6);
			l.add(bullet);
		}
		/*else if (direction == "nowhere") {
			Bullet bullet = new Bullet(getx(),gety()+80,"bullet16x16-1.png");
			bullet.setdx(-6);
			l.add(bullet);
		}*/
            }
}

};

